<?xml version="1.0" encoding="utf-8" ?> 
<xs:schema targetNamespace="http://schemas.microsoft.com/VisualStudio/2008/workitemtracking/typelib"
                  elementFormDefault="unqualified"
                  attributeFormDefault="unqualified" 
                  xmlns="http://schemas.microsoft.com/VisualStudio/2008/workitemtracking/typelib"
                  xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <!-- Simple types -->
    <!-- Any constant -->
    <xs:simpleType name="Constant">
        <xs:restriction base="xs:string">
            <xs:maxLength value="255"/>
        </xs:restriction>
    </xs:simpleType>
    <!-- Plain constant (no user names) -->
    <xs:simpleType name="PlainConstant">
        <xs:restriction base="Constant">
            <!-- Backslashes are prohibited! -->
            <xs:pattern value="^[^\\]*$"/>
        </xs:restriction>
    </xs:simpleType>
    <!-- Non-empty constant -->
    <xs:simpleType name="NonEmptyConstant">
        <xs:restriction base="Constant">
            <xs:minLength value="1"/>
        </xs:restriction>
    </xs:simpleType>
    <!-- Non-empty plain constant -->
    <xs:simpleType name="NonEmptyPlainConstant">
        <xs:restriction base="PlainConstant">
            <xs:minLength value="1"/>
        </xs:restriction>
    </xs:simpleType>
    <!-- Global list name -->
    <xs:simpleType name="GlobalListName">
        <xs:restriction base="NonEmptyPlainConstant">
            <xs:maxLength value="254"/>
        </xs:restriction>
    </xs:simpleType>
    <!-- Identity name -->
    <xs:simpleType name="IdentityName">
        <xs:restriction base="xs:token">
            <xs:minLength value="1"/>
            <xs:maxLength value="255"/>
            <xs:pattern value="^[^\\]+\\[^\\]+$"/>
        </xs:restriction>
    </xs:simpleType>
    <!-- Non-empty large text-->
    <xs:simpleType name="NonEmptyLargeText">
        <xs:restriction base="xs:string">
            <xs:minLength value="1" />
        </xs:restriction>
    </xs:simpleType>

    <!-- Any name -->
    <xs:simpleType name="Name">
        <xs:restriction base="xs:token">
            <xs:minLength value="1"/>
        </xs:restriction>
    </xs:simpleType>
    <!-- Friendly name -->
    <xs:simpleType name="FriendlyName">
        <xs:restriction base="Name">
            <xs:maxLength value="128" />
            <xs:pattern value="^[^\.\[\]]+$"/>
        </xs:restriction>
    </xs:simpleType>
    <!-- Friendly field name -->
    <xs:simpleType name="FieldName">
        <xs:restriction base="FriendlyName"/>
    </xs:simpleType>
    <!-- Reference name -->
    <xs:simpleType name="ReferenceName">
        <xs:restriction base="Name">
            <xs:maxLength value="70" />
            <xs:pattern value="^[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z0-9_]+)+$" />
        </xs:restriction>
    </xs:simpleType>
    <!-- Reference field name -->
    <xs:simpleType name="ReferenceFieldName">
        <xs:restriction base="ReferenceName"/>
    </xs:simpleType>
    
    <!-- Complex types-->
    <!-- Global lists definitions (GLOBALLISTS) -->
    <xs:complexType name="GlobalListsDef">
        <xs:sequence>
            <xs:element name="GLOBALLIST" type="GlobalListDef" minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
    </xs:complexType>
    <!-- Global list definition (GLOBALLIST) -->
    <xs:complexType name="GlobalListDef">
        <xs:sequence>
            <xs:element name="LISTITEM" type="ListItem" minOccurs="1" maxOccurs="unbounded" />
        </xs:sequence>
        <xs:attribute name="name" type="GlobalListName" use="required" />
    </xs:complexType>
    <!-- Global list reference (inside the list of values) -->
    <xs:complexType name="GlobalList">
        <xs:attribute name="name" type="GlobalListName" use="required"/>
    </xs:complexType>
    <!-- List item (LISTITEM) -->
    <xs:complexType name="ListItem">
        <xs:attribute name="value" type="NonEmptyConstant" use="required" />
    </xs:complexType>
</xs:schema>
